#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->mPox=0;
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    //painter绘制已经存在的图片
    QPainter painter(this);
    QPixmap pixmap(":/image/dog.PNG");
    painter.drawPixmap(mPox,0,pixmap);

}

void Widget::on_pushButton_clicked()
{
    mPox += 10;
    //重新绘制图片
    this->update();
}
